﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class Page_MasterPage : System.Web.UI.MasterPage
{

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (Session["UserName"] == null)
        {
            string currentURL = Request.Url.PathAndQuery;
            Response.Redirect("Login.aspx?returnURL=" + HttpUtility.UrlEncode(currentURL));
        }
        else
        {
            string currentPage = Path.GetFileName(Request.PhysicalPath);
            if (currentPage.ToLower() != "default.aspx")
            {
                GlobalVariable.CurrentPage = currentPage;
                if (!CheckRoles.CanView())
                {
                    Response.Redirect(ResolveUrl("~/Page/AccessDeny.aspx"));
                }
            }
            this.Literal_UserName.Text = GlobalVariable.CurrentUserName;
        }

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Page.Header.DataBind();

        if (!IsPostBack)
        {
        }
    }

    protected void LinkButton_Logout_Click(object sender, EventArgs e)
    {
        Session.Remove("NULL");
        Session.RemoveAll();
        Session.Abandon();
        string currentURL = Request.Url.PathAndQuery;
        Response.Redirect("Login.aspx?returnURL=" + HttpUtility.UrlEncode(currentURL));
    }

}
